import { defineStore } from 'pinia'
import { ref } from 'vue'
import storage from 'storejs'

export const useCompanyInfoStore = defineStore('companyInfoStore', () => {
  const state = ref({
    companyInfo: storage.get('companyInfo') || '', // 推送数据
  })
  const alarmNumState = ref({
    alarmNum: storage.get('alarmsObj') || {}, //告警数量
  })
  const setcompanyInfo = (payload) => {
    state.value.companyInfo = payload
    storage.set('companyInfo', payload)
  }
  const setAlarmNum = (payload) => {
    alarmNumState.value.alarmNum = payload
    storage.set('alarmsObj', payload)
  }

  return {
    state,
    setcompanyInfo,

    alarmNumState,
    setAlarmNum,
  }
})
